package com.zhangyu.shadow.repair.init;

import android.app.Application;
import android.content.Context;

import com.zhangyu.shadow.repair.aop.core.ILogin;
import com.zhangyu.shadow.repair.aop.core.LoginManager;
import com.zhangyu.shadow.repair.event.LogoutEvent;

import org.greenrobot.eventbus.EventBus;

import st.lib.base.account.AccountChecker;
import st.lib.base.itf.IComponentApplication;

/**
 * Description:
 *
 * @author Hequn.Lee
 * @date 2018/11/2
 */
public class RepairComponent implements IComponentApplication {

    @Override
    public void onCreate(Application application) {
        LoginManager.getInstance().init(mLogin);
    }

    @Override
    public void attachBaseContext(Context base) {

    }

    private ILogin mLogin = new ILogin() {
        @Override
        public void login(int userDefine) {
            switch (userDefine) {
                case 0:
                    //RootDelegate接收此事件
                    EventBus.getDefault().post(new LogoutEvent());
                    break;
                case 1:
                    break;
                default:
                    break;
            }
        }

        @Override
        public boolean isLogin() {
            return AccountChecker.checkAccount();
        }

        @Override
        public void clearLoginStatus() {
            AccountChecker.clearLoginStatus();
        }
    };
}
